package com.ruoyi.web.controller.teaching;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.student.domain.Student;
import com.ruoyi.teacher.domain.MyTask;
import com.ruoyi.teaching.dto.TaskupdateDto;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.teaching.domain.TeacherStalke;
import com.ruoyi.teaching.service.ITeacherStalkeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 老师跟踪
 * Controller
 *lbj
 * @author ruoyi
 * @date 2023-05-18
 */
@RestController
@RequestMapping("/teaching/stalke")
public class TeacherStalkeController extends BaseController {
    @Autowired
    private ITeacherStalkeService teacherStalkeService;




    /**
     * 查询老师跟踪
     * 列表
     */
    @PreAuthorize("@ss.hasPermi('teaching:stalke:list')")
    @GetMapping("/list")
    public TableDataInfo list(TeacherStalke teacherStalke) {
        startPage();
        List<TeacherStalke> list = teacherStalkeService.selectTeacherStalkeList(teacherStalke);
        return getDataTable(list);
    }

    /**
     * 导出老师跟踪
     列表
     */
    @PreAuthorize("@ss.hasPermi('teaching:stalke:export')")
    @Log(title = "老师跟踪", businessType = BusinessType.EXPORT)
            @PostMapping("/export")
            public void export(HttpServletResponse response, TeacherStalke teacherStalke) {
        List<TeacherStalke> list = teacherStalkeService.selectTeacherStalkeList(teacherStalke);
        ExcelUtil<TeacherStalke> util = new ExcelUtil<TeacherStalke>(TeacherStalke.class);
        util.exportExcel(response, list, "老师跟踪数据");
    }

    /**
     * 获取老师跟踪
     * 详细信息
     */
    @PreAuthorize("@ss.hasPermi('teaching:stalke:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(teacherStalkeService.selectTeacherStalkeById(id));
    }
    /**
     * 根据学生Id获取老师跟踪
     * 详细信息
     */
    @PreAuthorize("@ss.hasPermi('teaching:stalke:query')")
    @GetMapping(value = "/findByStudentId/{studentId}")
    public AjaxResult findByStudentId(@PathVariable("studentId") Long studentId) {
        return success(teacherStalkeService.findByStudentId(studentId));
    }
    /**
     * 根据学生Id获取学生的追踪记录
     * 详细信息
     */
    @PreAuthorize("@ss.hasPermi('teaching:stalke:query')")
    @GetMapping(value = "/getfindListByStudentId//{studentId}")
    public AjaxResult getfindListByStudentId(@PathVariable("studentId") Long studentId) {
        return success(teacherStalkeService.getfindListByStudentId(studentId));
    }

    /**
     * 根据我的任务Id获取学生的任务记录
     * 详细信息
     */
    @PreAuthorize("@ss.hasPermi('teaching:stalke:query')")
    @PostMapping(value = "/getfindListmodifyHistorys")
    public AjaxResult getfindListmodifyHistorys(@RequestBody Student student) {

        String name = student.getName();
        System.out.println(name);
        List<MyTask> myTasks = teacherStalkeService.getfindListmodifyHistorys(name);

        return success(teacherStalkeService.getfindListmodifyHistorys(name));
    }


    /**
     * 根据学生Id获取学生的追踪记录
     * 详细信息
     */
    @PreAuthorize("@ss.hasPermi('teaching:stalke:taskupdate')")
    @PostMapping (value = "/gettaskupdate")
    public AjaxResult gettaskupdate(@RequestBody TaskupdateDto dto) {

        return success(teacherStalkeService.gettaskupdate(dto));
    }


    /**
     * 新增老师跟踪

     */
    @PreAuthorize("@ss.hasPermi('teaching:stalke:add')")
    @Log(title = "老师跟踪", businessType = BusinessType.INSERT)
            @PostMapping
            public AjaxResult add(@RequestBody TeacherStalke teacherStalke)
            {
            return toAjax(teacherStalkeService.insertTeacherStalke(teacherStalke));
            }

            /**
             * 修改老师跟踪

            */
            @PreAuthorize("@ss.hasPermi('teaching:stalke:edit')")
            @Log(title = "老师跟踪", businessType = BusinessType.UPDATE)
            @PutMapping
            public AjaxResult edit(@RequestBody TeacherStalke teacherStalke)
            {
            return toAjax(teacherStalkeService.updateTeacherStalke(teacherStalke));
            }

            /**
             * 删除老师跟踪

            */
            @PreAuthorize("@ss.hasPermi('teaching:stalke:remove')")
            @Log(title = "老师跟踪", businessType = BusinessType.DELETE)
            @DeleteMapping("/{ids}")
            public AjaxResult remove(@PathVariable Long[]ids) {
        return toAjax(teacherStalkeService.deleteTeacherStalkeByIds(ids));
    }
}
